#include <iostream>
#include <algorithm>

using namespace std;
typedef long long LL;
int n;
const int N = 310;
LL h[N];
int main()
{
	cin >> n;

	for (int i = 1; i <= n; i++) cin >> h[i];

	sort(h + 1, h + 1 + n);
	int l = 0, r = n;
	LL sum = 0;
	while (l < r)
	{
		sum += (h[l] - h[r]) * (h[l] - h[r]);
		l++;
		sum += (h[l] - h[r]) * (h[l] - h[r]);
		r--;
	}
	cout << sum << endl;
	return 0;
}